﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Focus();//让光标定位到text1上
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text=="")
            {
                MessageBox.Show("用户名不能为空！","提示");
                textBox1.Focus();
            }
            else if(textBox2.Text=="")
            {
                MessageBox.Show("密码不能为空！","提示");
                textBox2.Focus();
            }
            else
            {
                if (textBox1.Text=="admin" && textBox2.Text=="123")
                {
                    MessageBox.Show("登录成功！","登录");

                }
                else
                {
                    MessageBox.Show("账号或密码不正确！","提示");
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox1.Focus();
                }
            }
        }
    }
}
